<html>
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>Ajax增删改查Demo</title>
	<style>
		body{
			height: 100%;
			overflow: hidden;
		}
		.main{
			display: flex;
			height: 50px;
			padding: 5px 10px;
		}
		.main .item{
			flex: 1;
			height: 30px;
			padding: 10px;
			font-size: 18px;
			color: #007AFF;
			text-align: center;
			border: 1px solid #10AEFF;
			margin: 5px;
		}
		
		.main .item:hover{
			background-color: #F3F3F3;
		}
		.show{
			padding: 20px;
		}
	</style>
</head>
<body>
	<div class="main">
		<div id="add" class="item">增</div>
		<div id="del" class="item">删</div>
		<div id="edit" class="item">改</div>
		<div id="sel" class="item">查</div>
		<div id="login" class="item">login</div>
	</div>
	<div class="show">
	
					<div class="weui-flex item-line">
						<div class="my-flex"></div>
						<div class="line"></div>
						<div class="my-flex"></div>
					</div>

					<div class="weui-flex item-box">
						<div class="my-flex left">
							<label>0.00</label>
							<label>收入</label>
						</div>
						<div class="text-box">19</div>
						<div class="my-flex right">
							<label>支出</label>
							<label>888.00</label>
						</div>
					</div>

					<div class="weui-flex item-line">
						<div class="my-flex"></div>
						<div class="line"></div>
						<div class="my-flex"></div>
					</div>

					<div class="weui-flex item-box">
						<!-- 删除 -->
						<div class="item-btn-delete action">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-cha"></use>
							</svg>
						</div>
						<div class="my-flex left">
							
						</div>
						<div class="icon-box item-icon-btn" style="background-color: #9CE3E7;border-color: #9CE3E7;">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-biandangicon"></use>
							</svg>
						</div>
						<div class="my-flex right">
							<label>电影</label>
							<label>888.00</label>
						</div>
						<!-- 编辑 -->
						<div class="item-btn-edit action">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-qianbipencil82"></use>
							</svg>
						</div>
					</div>

					<div class="weui-flex item-line">
						<div class="my-flex"></div>
						<div class="line"></div>
						<div class="my-flex"></div>
					</div>

					<div class="weui-flex item-box">
						<div class="my-flex left">
							<label class="month-text">5月</label>
						</div>
						<div class="month-box"></div>
						<div class="my-flex right"></div>
					</div>

					<div class="weui-flex item-line">
						<div class="my-flex"></div>
						<div class="line"></div>
						<div class="my-flex"></div>
					</div>

					<div class="weui-flex item-box">
						<div class="my-flex left">
							<label>0.00</label>
							<label>收入</label>
						</div>
						<div class="text-box">19</div>
						<div class="my-flex right">
							<label>支出</label>
							<label>88.00</label>
						</div>
					</div>

					<div class="weui-flex item-line">
						<div class="my-flex"></div>
						<div class="line"></div>
						<div class="my-flex"></div>
					</div>

					<div class="weui-flex item-box">
						<!-- 删除 -->
						<div class="item-btn-delete action">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-cha"></use>
							</svg>
						</div>
						<div class="my-flex left"></div>
						<div class="icon-box item-icon-btn" style="background-color: #A5B6FF;border-color: #A5B6FF;">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-fantuanicon-"></use>
							</svg>
						</div>
						<div class="my-flex right">
							<label>电影</label>
							<label>80.00</label>
						</div>
						<!-- 编辑 -->
						<div class="item-btn-edit action">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-qianbipencil82"></use>
							</svg>
						</div>
					</div>

					<div class="weui-flex item-line">
						<div class="my-flex"></div>
						<div class="line"></div>
						<div class="my-flex"></div>
					</div>

					<div class="weui-flex item-box">
						<!-- 删除 -->
						<div class="item-btn-delete action">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-cha"></use>
							</svg>
						</div>
						<div class="my-flex left"></div>
						<div class="icon-box item-icon-btn" style="background-color: #B5E384;border-color: #B5E384;">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-bingganicon-"></use>
							</svg>
						</div>
						<div class="my-flex right">
							<label>零食</label>
							<label>8.00</label>
						</div>
						<!-- 编辑 -->
						<div class="item-btn-edit action">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-qianbipencil82"></use>
							</svg>
						</div>
					</div>
					
					<div class="weui-flex item-line">
						<div class="my-flex"></div>
						<div class="line"></div>
						<div class="my-flex"></div>
					</div>

					<div class="weui-flex item-box">
						<div class="my-flex left">
							<label>0.00</label>
							<label>收入</label>
						</div>
						<div class="text-box">18</div>
						<div class="my-flex right">
							<label>支出</label>
							<label>8.00</label>
						</div>
					</div>
					
					<div class="weui-flex item-line">
						<div class="my-flex"></div>
						<div class="line"></div>
						<div class="my-flex"></div>
					</div>
					
					<div class="weui-flex item-box">
						<!-- 删除 -->
						<div class="item-btn-delete action">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-cha"></use>
							</svg>
						</div>
						<div class="my-flex left"></div>
						<div class="icon-box item-icon-btn" style="background-color: #B5E384;border-color: #B5E384;">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-bingganicon-"></use>
							</svg>
						</div>
						<div class="my-flex right">
							<label>零食</label>
							<label>8.00</label>
						</div>
						<!-- 编辑 -->
						<div class="item-btn-edit action">
							<svg class="icon" aria-hidden="true">
								<use xlink:href="#icon-qianbipencil82"></use>
							</svg>
						</div>
					</div>
	
	
	
	
	
	
	
	</div>
	
	<script src="js/jquery-1.9.1.min.js"></script>
	<script src="js/api.js"></script>
	<script>
		$(function() {
			$('#add').click(function(){
				a();
			});
			$('#del').click(function(){
				b();
			});
			$('#edit').click(function(){
				c();
			});
			$('#sel').click(function(){
				d();
			});
			$('#login').click(function(){
				login();
			});
		});
		var add = 'http://api.yttrium2016.cn/cors/my-add';
		var find = "http://api.yttrium2016.cn/cors/my-find"
		var size = "http://api.yttrium2016.cn/cors/my-size"
		
		function login(){
			API.login('yzy','123',function(data){
				alert(JSON.stringify(data));
			})
		}
		
		function a(){
			
			var b = ['#F7AEDE','#A5DFFF','#FFCB7B','#A5B6FF','#A5CBFF','#FFDF73','#BDE384','#9CE3DE'
					,'#C6AEF7','#C6BAEF','#8CCBF7','#FF929C','#E7CFB5','#ADAAAD'];
			var a = ['#icon-ziyuan19','#icon-ziyuan14','#icon-ziyuan12'];
			for (var i = 0; i < a.length; i++) {
				API.addIcon(a[i],function(data){
					console.log(JSON.stringify(data));
				})
			}
			
		}
		
		function b(){
			var data = {"data":{"username":"test"},"id":2,"tableName":"user"};
			$.ajax({
			    type: "post",
		//      async: false,
		        url: API.Url.edit,
		        dataType: "json",
		        data: {
		            "data": JSON.stringify(data)
		        },
		        success: function (data, textStatus) {
		        	console.log(data,2);
		        }
		        , error: function () {
		        	console.log('API.login error');
		    	}
		    });
		}
		
		function c(){
			console.log(API.getStorage("a"));
		}
	
		function d(){
			var i = 27;
			var url = 'http://api.yttrium2016.cn/cors/my-delete'
			for(i = 27;i<157;i++){
				var d = {"data":{},"id":i,"tableName":"tag"};
				$.ajax({
				    type: "post",
			        url: url,
			        dataType: "json",
			        data: {
			            "data": JSON.stringify(d)
			        },
			        success: function (data, textStatus) {
			        	if(data.data == 1){
			        		console.log(i+"删除成功");
			        	}
			        }
			    });
			}
		}
	</script>
</body>
</html>